#!/bin/bash

# $Id: elektro.sh,v 1.5 2006/03/10 21:41:09 Platyna Exp $
#----------------------------------------------------------------------
# Description: Simple script to control eAthena locally.
# Author: Zuzanna K. Filutowska <platyna@platinum.linux.pl>
# Created at: Fri Feb 17 18:23:56 CET 2006
# License: GPL
# Copyright (c) 2006 Zuzanna K. Filutowska  All rights reserved.
#
#----------------------------------------------------------------------
# Configure section:
PATH=$PATH:.
SRVHOMEDIR=/home/elektrogame/elektroserver/trunk
#----------------------------------------------------------------------
# main()

cd ${SRVHOMEDIR}

elektro_start() {
    if [ -x ${SRVHOMEDIR}/elektro-monitor ]; 
	then echo "Starting elektro monitor..."
	     ${SRVHOMEDIR}/elektro-monitor
	else echo "Eathena monitor binary is not executable or not found."
    fi
}

elektro_stop() {
    echo "Shutting down elektro monitor..."
    killall elektro-monitor
}

elektro_restart() {
    elektro-monitor
    echo "Waiting for all elektro processes to end..."
    sleep 1
    elektro-monitor
}

case "$1" in
'start')
  elektro_start
  ;;
'stop')
  elektro_stop
  ;;
'restart')
  elektro_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac
